﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace NoDriverPrintHelperV1d0.Entity
{
    [XmlRoot("小票打印配置信息集")]
    public class TicketPrintConfigInfoV1d0
    {
        /// <summary>
        /// 重要信息
        /// </summary>
        [XmlElement("重要信息")]
        public PrintTextInfoV1d0 Zyxx { get; set; }
        /// <summary>
        /// 快餐信息
        /// </summary>
        [XmlElement("快餐信息")]
        public PrintTextInfoV1d0 Kcxx { get; set; }
        /// <summary>
        /// 台号
        /// </summary>
        
        [XmlElement("台号")]
        public PrintTextInfoV1d0 Th { get; set; }
        /// <summary>
        /// 打印时间
        /// </summary>
        [XmlElement("打印时间")]
        public PrintTextInfoV1d0 Dysj { get; set; }
        [XmlElement("内容主项")]
        public PrintTextInfoV1d0 ContentMainItem { get; set; }
        [XmlElement("内容子项")]
        public PrintTextInfoV1d0 ContentSubItem { get; set; }
        
        /// <summary>
        /// 打印序号
        /// </summary>
        [XmlElement("打印序号")]
        public PrintTextInfoV1d0 Dyxh { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        [XmlElement("备注")]
        public PrintTextInfoV1d0 Bz { get; set; }

        public TicketPrintConfigInfoV1d0()
        {
            Zyxx = new PrintTextInfoV1d0();

            Kcxx = new PrintTextInfoV1d0();

            Th = new PrintTextInfoV1d0();

            Dysj = new PrintTextInfoV1d0();

            ContentMainItem = new PrintTextInfoV1d0();

            ContentSubItem = new PrintTextInfoV1d0();

            Dyxh = new PrintTextInfoV1d0();

            Bz = new PrintTextInfoV1d0();
        }

        /// <summary>
        /// 从配置数据保存到xml文件
        /// </summary>
        /// <param name="data"></param>
        /// <param name="xmlFilename"></param>
        public static void SavaToXml(TicketPrintConfigInfoV1d0 data, string xmlFilename)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(TicketPrintConfigInfoV1d0));
            StreamWriter sW = new StreamWriter(xmlFilename);
            try
            {
                xmlSerializer.Serialize(sW, data);
            }
            finally
            {
                sW.Close();
            }
        }

        /// <summary>
        /// 从xml文件读取配置数据
        /// </summary>
        /// <param name="xmlFilename"></param>
        /// <returns></returns>
        public static TicketPrintConfigInfoV1d0  LoadFromXml(string xmlFilename)
        {
            TicketPrintConfigInfoV1d0 resultData = null;
            try
            {
                if (File.Exists(xmlFilename))
                {
                    StreamReader sR = new StreamReader(xmlFilename);
                    XmlSerializer xmlS = new XmlSerializer(typeof(TicketPrintConfigInfoV1d0));
                    resultData = (TicketPrintConfigInfoV1d0)xmlS.Deserialize(sR);
                    sR.Close();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + ex.StackTrace);
            }
            return resultData;
        }



    }
    /// <summary>
    /// 小票打印内容信息
    /// </summary>
    [XmlRoot("小票打印内容信息集")]
    public class TicketPrintContentInfoV1d0
    {
        /// <summary>
        /// 重要信息
        /// </summary>
        [XmlElement("重要信息")]
        public PrintTextInfoV1d0 Zyxx { get; set; }
        /// <summary>
        /// 快餐信息
        /// </summary>
        [XmlElement("快餐信息")]
        public PrintTextInfoV1d0 Kcxx { get; set; }
        /// <summary>
        /// 台号
        /// </summary>

        [XmlElement("台号")]
        public PrintTextInfoV1d0 Th { get; set; }
        /// <summary>
        /// 打印时间
        /// </summary>
        [XmlElement("打印时间")]
        public PrintTextInfoV1d0 Dysj { get; set; }
        [XmlArray("菜单内容"), XmlArrayItem("菜单项")]
        public List<PrintTextInfoV1d0> Content { get; set; }
                /// <summary>
        /// 打印序号
        /// </summary>
        [XmlElement("打印序号")]
        public PrintTextInfoV1d0 Dyxh { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        [XmlElement("备注")]
        public PrintTextInfoV1d0 Bz { get; set; }

        public TicketPrintContentInfoV1d0()
        {
            Zyxx = new PrintTextInfoV1d0();

            Kcxx = new PrintTextInfoV1d0();

            Th = new PrintTextInfoV1d0();

            Dysj = new PrintTextInfoV1d0();

            Content = new List<PrintTextInfoV1d0>();
            Content.Add(new PrintTextInfoV1d0());
            Content.Add(new PrintTextInfoV1d0());

            Dyxh = new PrintTextInfoV1d0();

            Bz = new PrintTextInfoV1d0();
        }
        /// <summary>
        /// 从配置数据保存到xml文件
        /// </summary>
        /// <param name="data"></param>
        /// <param name="xmlFilename"></param>
        public static void SavaToXml(TicketPrintContentInfoV1d0 data, string xmlFilename)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(TicketPrintContentInfoV1d0));
            StreamWriter sW = new StreamWriter(xmlFilename);
            try
            {
                xmlSerializer.Serialize(sW, data);
            }
            finally
            {
                sW.Close();
            }
        }

        /// <summary>
        /// 从xml文件读取配置数据
        /// </summary>
        /// <param name="xmlFilename"></param>
        /// <returns></returns>
        public static TicketPrintContentInfoV1d0 LoadFromXml(string xmlFilename)
        {
            TicketPrintContentInfoV1d0 resultData = null;
            try
            {
                if (File.Exists(xmlFilename))
                {
                    StreamReader sR = new StreamReader(xmlFilename);
                    XmlSerializer xmlS = new XmlSerializer(typeof(TicketPrintContentInfoV1d0));
                    resultData = (TicketPrintContentInfoV1d0)xmlS.Deserialize(sR);
                    sR.Close();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + ex.StackTrace);
            }
            return resultData;
        }
    }
    [XmlRoot("小票打印模板")]
    public class TicketPrintTempletV1d0
    {
        /// <summary>
        /// 重要信息
        /// </summary>
        [XmlElement("重要信息")]
        public PrintTaskItemV1d0 Zyxx { get; set; }
        /// <summary>
        /// 快餐信息
        /// </summary>
        [XmlElement("快餐信息")]
        public PrintTaskItemV1d0 Kcxx { get; set; }
        /// <summary>
        /// 台号
        /// </summary>

        [XmlElement("台号")]
        public PrintTaskItemV1d0 Th { get; set; }
        /// <summary>
        /// 打印时间
        /// </summary>
        [XmlElement("打印时间")]
        public PrintTaskItemV1d0 Dysj { get; set; }
        [XmlArray("菜式明细列表"), XmlArrayItem("菜式")]
        public List<PrintTaskItemV1d0> DishDetailList { get; set; }
        /// <summary>
        /// 打印序号
        /// </summary>
        [XmlElement("打印序号")]
        public PrintTaskItemV1d0 Dyxh { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        [XmlElement("备注")]
        public PrintTaskItemV1d0 Bz { get; set; }

        public TicketPrintTempletV1d0()
        {
            Zyxx = new PrintTaskItemV1d0(0);

            Kcxx = new PrintTaskItemV1d0(1);

            Th = new PrintTaskItemV1d0(2);

            Dysj = new PrintTaskItemV1d0(3);

            //从10开始编号
            DishDetailList = new List<PrintTaskItemV1d0>();

            Dyxh = new PrintTaskItemV1d0(100);

            Bz = new PrintTaskItemV1d0(101);
        }

        /// <summary>
        /// 从配置数据保存到xml文件
        /// </summary>
        /// <param name="data"></param>
        /// <param name="xmlFilename"></param>
        public static void SavaToXml(TicketPrintTempletV1d0 data, string xmlFilename)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(TicketPrintTempletV1d0));
            StreamWriter sW = new StreamWriter(xmlFilename);
            try
            {
                xmlSerializer.Serialize(sW, data);
            }
            finally
            {
                sW.Close();
            }
        }

        /// <summary>
        /// 从xml文件读取配置数据
        /// </summary>
        /// <param name="xmlFilename"></param>
        /// <returns></returns>
        public static TicketPrintTempletV1d0 LoadFromXml(string xmlFilename)
        {
            TicketPrintTempletV1d0 resultData = null;
            try
            {
                if (File.Exists(xmlFilename))
                {
                    StreamReader sR = new StreamReader(xmlFilename);
                    XmlSerializer xmlS = new XmlSerializer(typeof(TicketPrintTempletV1d0));
                    resultData = (TicketPrintTempletV1d0)xmlS.Deserialize(sR);
                    sR.Close();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + ex.StackTrace);
            }
            return resultData;
        }



    }
    [XmlRoot("Guid测试")]
    public class GuidV1d0
    {
        /// <summary>
        /// 重要信息
        /// </summary>
        [XmlElement("重要信息")]
        public PrintTaskItemV1d0 Zyxx { get; set; }


        public GuidV1d0()
        {
            Zyxx = new PrintTaskItemV1d0();
        }

        /// <summary>
        /// 从配置数据保存到xml文件
        /// </summary>
        /// <param name="data"></param>
        /// <param name="xmlFilename"></param>
        public static void SavaToXml(GuidV1d0 data, string xmlFilename)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(GuidV1d0));
            StreamWriter sW = new StreamWriter(xmlFilename);
            try
            {
                xmlSerializer.Serialize(sW, data);
            }
            finally
            {
                sW.Close();
            }
        }

        /// <summary>
        /// 从xml文件读取配置数据
        /// </summary>
        /// <param name="xmlFilename"></param>
        /// <returns></returns>
        public static GuidV1d0 LoadFromXml(string xmlFilename)
        {
            GuidV1d0 resultData = null;
            try
            {
                if (File.Exists(xmlFilename))
                {
                    StreamReader sR = new StreamReader(xmlFilename);
                    XmlSerializer xmlS = new XmlSerializer(typeof(GuidV1d0));
                    resultData = (GuidV1d0)xmlS.Deserialize(sR);
                    sR.Close();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + ex.StackTrace);
            }
            return resultData;
        }



    }
}
